local StageUILayer=class("StageUILayer",FZutil.createTransportUILayer)

function StageUILayer:ctor()
    self:enableNodeEvents()
	local uimap=FZutil.createSceneNode("StageUI")
	self:addChild(uimap.root)
	self.uimap=uimap
	
    local centerNode=uimap.root
    --centerNode:setScale(0)
    --centerNode:setPosition(display.center)

    local Node_fastBtn = uimap.Node_fastBtn   
    local Button_fast = uimap.Button_fast
    local Panel_fast = uimap.Panel_fast
    local Button_cheat = uimap.Button_cheat
    local Button_trade = uimap.Button_trade
    local Button_tx = uimap.Button_tx
    local Text_location = uimap.Text_location

    local function txTouch(e)
        if e.name=="ended" then
        	self.isShowRain = not self.isShowRain
            if self.isShowRain then
                --NetEngine:sendMessage(ProtoCmd.ReqExecGMCmdMessage,{param="@生产2 1001 100 2"})       
                self:playRain()
            else
                self.ccArmatureWeather:removeFromParent()
            end  
        end
    end
    Button_tx:onTouch(txTouch)
    local function cheatTouch(e)
        if e.name=="ended" then
        	MyApp:enterScene("CheatScene")
        end
    end
    Button_cheat:onTouch(cheatTouch)
    local function grideTouch(e)
        if e.name=="ended" then
        	self.isShowNode = not self.isShowNode
            MapController:getCurMap():setVisibleDrawNode(self.isShowNode)
        end
    end
    Button_fast:onTouch(grideTouch)
	print(Button_fast:getPosition())

    local function tradeTouch(e)
        if e.name=="ended" then
            local TradeUILayer = require("app.layers.trade_TradeUILayer")
        	display.getRunningScene():addChild(TradeUILayer.new())
        end
    end
    Button_trade:onTouch(tradeTouch)
    --FZutil.windowShowEff(centerNode)
end

function StageUILayer:updateContent()
    local location = MapController:getCurPlayerCtrl():getCurrLocation()
    self.uimap.Text_location:setString(string.format("(%d,%d)",location.x,location.y))
end

function StageUILayer:playRain()
    ccs.ArmatureDataManager:getInstance():addArmatureFileInfo("tx/TX_tianqi3/TX_tianqi3.ExportJson")
    local sz = string.format("TX_tianqi%d",3)
	self.ccArmatureWeather = ccs.Armature:create(sz)
	self.ccArmatureWeather:getAnimation():play("cast")
	self.ccArmatureWeather:setPosition(display.center)
	self:addChild(self.ccArmatureWeather)
end

function StageUILayer:onEnter()
    self.isShowNode = false
    self.isShowRain = false
end

function StageUILayer:onExit()
    
end

return StageUILayer